package com.sxl.controller;
import com.sxl.config.LayUiResult;
import com.sxl.domain.Users;
import org.springframework.web.bind.annotation.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author shkstart
 * @create 2022-03-12 下午 1:03
 */
@RestController
@RequestMapping("/allocation")
@CrossOrigin
public class allocationSwitchController {
    public static String autoAllocateSwitch = "off";


    /**
     * 读取开关数据
     */
    @GetMapping("/find")
    public Map<String, Object> findByPage(Users users) {
        Map<String,Object> map=new HashMap<>();
        map.put("isLock",autoAllocateSwitch.equals("on") ? "1" :"0");
        List<Map<String, Object>> list = new ArrayList<>();
        list.add(map);
        return LayUiResult.toClient("0", "success", 1, list);
    }
/**
 * 处理开关
 */
      @PostMapping("set")
    public boolean set(String valid){
          autoAllocateSwitch=valid;
          return autoAllocateSwitch.equals(valid);
      }
}
